#-*-coding=utf-8-*-
from django.db import models
from people.models import Person
from grades.models import Period, Cycle, Grade, ScholarClass


class Message(models.Model):
	class Meta:
		verbose_name = "Mensagem"
		verbose_name_plural = "Mensagens"
	sender = models.ForeignKey(Person, verbose_name="Remetente")
	subject = models.CharField(max_length=100, verbose_name="Assunto")
	receiver_periods = models.ManyToManyField(Period, verbose_name="Períodos")
	receiver_cycles = models.ManyToManyField(Cycle, verbose_name="Ciclos")
	receiver_grades = models.ManyToManyField(Grade, verbose_name="Anos")
	receiver_scholar_classes = models.ManyToManyField(ScholarClass, verbose_name="Turmas")
	receiver_people = models.ManyToManyField(Person, verbose_name="Pessoas", related_name="received_message")
	plain_content = models.CharField(max_length=2000, verbose_name="Conteúdo texto")
	markup_content = models.CharField(max_length=10000, verbose_name="Conteúdo markup")
	video_content = models.FileField(upload_to="videos", verbose_name="Conteúdo vídeo")
	audio_content = models.FileField(upload_to="audio", verbose_name="Conteúdo áudio")

class Delivery(models.Model):
	class Meta:
		verbose_name = "Entrega"
		verbose_name_plural = "Entregas"
	message = models.ForeignKey(Message, verbose_name="Mensagem")
	receiver = models.ForeignKey(Person, verbose_name="Destinatário")
	delivered = models.BooleanField(verbose_name="Entregue")
	read = models.BooleanField(verbose_name="Lido")
